package com.lds.register.center.server.business.cluster.converter;

import com.lds.register.center.common.model.cluster.request.ClusterBaseUpdateRequest;
import com.lds.register.center.server.business.cluster.entity.Cluster;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;


@Component
public class ClusterBaseUpdateRequestToEntityConverter implements Converter<ClusterBaseUpdateRequest, Cluster> {

    @Override
    public Cluster convert(ClusterBaseUpdateRequest source) {
        return Cluster.builder()
                .id(source.getId())
                .modifier(source.getModifier())
                .updateTime(LocalDateTime.now())
                .name(source.getName())
                .envId(source.getEnvId())
                .desc(source.getDesc())
                .build();
    }

}


